const express = require("express");
const bodyParser = require("body-parser");
const { resolve } = require("path");
const webpackMiddleware = require("../webpack.middleware");

const port = process.env.PORT || 3000;
const app = express();
const router1 = express.Router();
function start() {
  const router = express.Router();
  webpackMiddleware(app);
  app.use(express.static(resolve(__dirname, "./public")));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: true }));
  router1.get("/a", (req, res) => {
    res.json({
      text: "123",
    });
  });
  app.use("/app", router1);
  app.use(router);
  // ...代码
  app.get("/", (req, res) => {
    res.json({
      text: "hello world1222",
    });
  });
  var server = app.listen(port, () => {
    console.log(`服务器端启动成功 当前服务进程${port}`);
  });
}

start();
